﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using yiCommerce.Core;
using yiCommerce.Core.Domain.Products;
using yiCommerce.Core.Helper;
using yiCommerce.Service.Loggings;
using yiCommerce.Service.Products;

namespace yiCommerce.Admin.Controllers.api
{
    public class InsertProductPictureRequest
    {
        public int PictureId { get; set; }
        public int ProductId { get; set; }
    }

    public class InsertProductPictureResult
    {
        public string Status { get; set; }

        public string Message { get; set; }
    }
    public class ProductPictureApiController : ApiController
    {
        private IProductService  _productService;
        private IActivityService _activityService;
        private IWorkContext _workContext;

        public ProductPictureApiController(IProductService productService, IActivityService activityService, IWorkContext workContext)
        {
            _productService = productService;
            _activityService = activityService;
            _workContext = workContext;
        }

        public InsertProductPictureResult InsertProductPicture(InsertProductPictureRequest request)
        {
            var result = new InsertProductPictureResult();


            try
            {

                _productService.InsertProductPicture(request.ProductId, request.PictureId,0);

                result.Status = "0";

                _activityService.InsertActivity("InsertProductPicture", JsonHelper.ToJson(request), _workContext.CurrentCustomer);
                //SuccessNotification(_localizationService.GetResource("Admin.Catalog.Products.Added"));
                return result;
            }
            catch (Exception e)
            {
                result.Status = "1";
                result.Message = e.ToString();
                return result;
            }

            return result;
        }
    }
}
